Warning: Declaration of AMW_Related_Sub_Items_Walker::walk($elements, $max_depth) should be compatible with Walker::walk($elements, $max_depth, ...$args) in /home/bu1hme7g/public_html/sleepandgo.es/wp-content/plugins/advanced-menu-widget/class-advanced-menu-walker.php on line 332
// source --> http://www.sleepandgo.es/wp-content/themes/business-world/inc/js/responsive.js?ver=1.1.26
var wdwt_window_cur_size = 'screen';
jQuery('document').ready(function ()
{
//var previus_view=document.getElementById('top_posts_web').innerHTML;
//screenSize=jQuery(".container").width();
jQuery('.cont_vat_tab ul.content > li').filter(function ()
{
return jQuery(this).css("display") != 'none'
}).addClass('active');
jQuery('#wd-categories-tabs > .tabs > li').eq(0).addClass('active');
sliderHeight = parseInt(jQuery("#slider-wrapper").height());
sliderWidth = parseInt(jQuery("#slider-wrapper").width());
sliderIndex = sliderHeight / sliderWidth;
if (matchMedia('only screen and (max-width : 767px)').matches) {
phone();
}
else
if (matchMedia('only screen and (min-width: 768px) and (max-width: 1024px)').matches) {
tablet();
}
else {
checkMedia();
}
add_top_posts_click();
var window_width = jQuery(window).width();
jQuery(window).resize(function ()
{
checkMedia();
});
function checkMedia()
{
//###############################SCREEN
if (matchMedia('only screen and (min-width: 1025px)').matches) {
screen();
}
//###############################TABLET
if (matchMedia('only screen and (min-width: 768px) and (max-width: 1024px)').matches) {
tablet();
}
//################################PHONE
if (matchMedia('only screen and (max-width : 767px)').matches) {
phone(false);
}
}
function screen()
{
slider.install('top-posts-list');
jQuery("#blog,.blog,#top-posts .container,#header-top + .container").removeAttr("style");
jQuery('.container>#blog').before(jQuery('#sidebar1'));
jQuery("#header .phone-menu-block").removeClass("container");
sHeight = sliderIndex * parseInt(jQuery("#slider-wrapper").width());
sliderSize(sHeight);
jQuery(".parallax-window").css("padding", "");
if (wdwt_window_cur_size == 'phone') {
jQuery("#header").find("#menu-button-block").remove();
jQuery("#top-nav").css({"display": "block"});
jQuery("#top-nav > div > ul li.addedli,#top-nav > div > div > ul li.addedli").remove();
jQuery("#header-top .container").append(jQuery("#social"));
jQuery("#header-middle").prepend(jQuery("#logo"));
jQuery("aside .sidebar-container .widget-area").removeClass("clear");
jQuery('#content').after(jQuery('#sidebar1'));
}
if (wdwt_window_cur_size == 'tablet') {
jQuery("#top-nav > div > ul li.addedli,#top-nav > div > div > ul li.addedli").remove();
}
if (wdwt_window_cur_size == 'phone' || wdwt_window_cur_size == 'tablet') {
jQuery("#top-posts-list> li .top-post-caption").removeClass('open');
jQuery("#top-posts-list> li .top-post-caption").removeClass('top_posts_hovered_caption');
}
jQuery('.cont_vat_tab ul.content').height(jQuery('.cont_vat_tab ul.content > li.active').filter(function ()
{
return jQuery(this).css("display") != "none"
}).height())
inserting_div_float_problem(jQuery('#sidebar-footer'));
resize_iframes();
wdwt_window_cur_size = 'screen';
}
function tablet()
{
slider.unbind();
var str = (jQuery(window).width() / 1024);
jQuery(".parallax-window").css("padding", business_world_options.wdwt_pinned_padding * str + "px 0");
jQuery('#blog').after(jQuery('#sidebar1'));
jQuery('.container>#content').after(jQuery('#content>#sidebar1'));
jQuery("#header .phone-menu-block").removeClass("container");
if (wdwt_window_cur_size == 'phone') {
jQuery("#header").find("#menu-button-block").remove();
jQuery("#top-nav").css({"display": "block"});
jQuery("#top-nav > div > ul li.addedli,#top-nav > div > div > ul li.addedli").remove();
jQuery("#header-top .container").append(jQuery("#social"));
jQuery("#header-middle").prepend(jQuery("#logo"));
jQuery("aside .sidebar-container .widget-area").removeClass("clear");
jQuery(".top-posts-block").width("100%");
}
jQuery("#top-nav > div > ul li.addedli,#top-nav > div > div > ul li.addedli").remove();
jQuery("#top-nav > div > ul li:has(> ul),#top-nav > div > div > ul li:has(> ul)").each(function ()
{
var strtext = jQuery(this).children("a").html();
var strhref = jQuery(this).children("a").attr("href");
var strlink = '' + strtext + '';
jQuery(this).children("ul").prepend('' + strlink + '');
});
jQuery('.cont_vat_tab ul.content').height(jQuery('.cont_vat_tab ul.content > li.active').filter(function ()
{
return jQuery(this).css("display") != "none"
}).height())
sHeight = sliderIndex * parseInt(jQuery("#slider-wrapper").width());
sliderSize(sHeight);
resize_iframes();
wdwt_window_cur_size = 'tablet';
}
function phone(full)
{
slider.unbind();
var str = (jQuery(window).width() / 1024);
jQuery(".parallax-window").css("padding", business_world_options.wdwt_pinned_padding * str + "px 0");
jQuery("#header .phone-menu-block").addClass("container");
jQuery('.container>#content').after(jQuery('.container>#sidebar1'));
jQuery('#blog').after(jQuery('#sidebar1'));
jQuery(".featured-content .single-post-text").after(jQuery(".featured-content img"));
sHeight = sliderIndex * parseInt(jQuery("#slider-wrapper").width());
sliderSize(sHeight);
//### PHONE UNIQUE STYLES
// jQuery(".cont_horizontal_tab").after(jQuery(".phone #tabs_div"))
jQuery("#top-nav > div > ul li.addedli,#top-nav > div > div > ul li.addedli").remove();
jQuery("#top-nav > div > ul li:has(> ul),#top-nav > div > div > ul li:has(> ul)").each(function ()
{
var strtext = jQuery(this).children("a").html();
var strhref = jQuery(this).children("a").attr("href");
var strlink = '' + strtext + '';
jQuery(this).children("ul").prepend('' + strlink + '');
});
if (wdwt_window_cur_size != 'phone') {
jQuery("#header-top .container").prepend(jQuery("#logo"));
}
for (var i = 0; i < jQuery("aside .sidebar-container .widget-area").length; i++) {
if (i % 2 == 0) {
jQuery("aside .sidebar-container .widget-area").eq(i).addClass("clear");
}
}
jQuery("#header").find("#menu-button-block").remove();
jQuery("#header .phone-menu-block").append('');
if (!jQuery("#top-nav").hasClass("open")) {
jQuery("#top-nav").css({"display": "none"})
}
;
jQuery('.cont_vat_tab ul.content').height(jQuery('.cont_vat_tab ul.content > li.active').filter(function ()
{
return jQuery(this).css("display") != "none"
}).height())
wdwt_window_cur_size = 'phone';
resize_iframes();
}
function add_top_posts_click()
{
jQuery("#top-posts-list> li").click(function ()
{
if (wdwt_window_cur_size == 'tablet' || wdwt_window_cur_size == 'phone') {
jQuery("#top-posts-list> li").find(".top-post-caption").removeClass("open").removeClass("top_posts_hovered_caption")
if (!jQuery(this).find(".top-post-caption").hasClass("open")) {
jQuery(this).find(".top-post-caption").addClass("open");
jQuery(this).find(".top-post-caption").addClass("top_posts_hovered_caption");
}
else {
jQuery(this).find(".top-post-caption").removeClass("open");
jQuery(this).find(".top-post-caption").removeClass("top_posts_hovered_caption");
}
}
}
);
}
function resize_iframes()
{
var allVideos = jQuery("iframe, object, embed");
allVideos.each(function ()
{
var el = jQuery(this);
fluidParent = el.parent();
var newWidth = fluidParent.width();
if (newWidth >= el.attr('data-origWidth')) {
newWidth = el.attr('data-origWidth');
}
el.width(newWidth)
.height(newWidth * el.attr('data-aspectRatio'));
});
}
function sliderSize(sHeight)
{
jQuery("#slider-wrapper").css('height', sHeight);
}
function inserting_div_float_problem(main_div)
{
jQuery(main_div).children('.clear:not(:last-child)').remove();
var iner_elements = jQuery(main_div).children();
var main_width = jQuery(main_div).width();
var summary_width = 0;
for (i = 0; i < iner_elements.length; i++) {
summary_width = summary_width + jQuery(iner_elements[i]).outerWidth();
if (summary_width > main_width) {
jQuery(iner_elements[i]).before('')
summary_width = jQuery(iner_elements[i]).outerWidth();
}
}
}
})
;
// source --> http://www.sleepandgo.es/wp-content/themes/business-world/inc/js/javascript.js?ver=1.1.26
var slider = {
element_id: 'top-posts-list',
hovered_width: 150,
standart_with: 150,
unhovered_width: 150,
childeren_count: 4,
animation_duration: 200,
install: function (ul_element_id)
{
this.element_id = ul_element_id;
this.generete_widths(this.element_id);
this.resize();
this.initial_start_widths();
this.set_widths(this.element_id);
},
generete_widths: function (ul_element_id)
{
this.main_ul_width = jQuery('#' + ul_element_id).parent().parent().width();
this.childeren_count = jQuery('#' + ul_element_id).children().length;
this.hovered_width = this.main_ul_width / 2;
if (this.childeren_count == 1) {
this.hovered_width = this.main_ul_width;
}
/*
if(this.childeren_count < 3){
this.childeren_count = 3;
}
*/
this.standart_with = this.main_ul_width / this.childeren_count;
this.unhovered_width = (this.hovered_width) / (this.childeren_count - 1);
},
initial_start_widths: function ()
{
this.generete_widths(this.element_id);
jQuery('#' + this.element_id).width(this.main_ul_width * this.childeren_count);
jQuery('#' + this.element_id).children().width(this.standart_with);
},
set_widths: function (ul_element_id)
{
locale_this = this;
jQuery('#' + ul_element_id).children().hover(gag_hover = function ()
{
jQuery(this).stop().animate({width: locale_this.hovered_width}, locale_this.animation_duration);
jQuery(this).parent().children().not(this).stop().animate({width: locale_this.unhovered_width}, locale_this.animation_duration)
}, gag_unhover = function ()
{
jQuery(this).parent().children().stop().animate({width: locale_this.standart_with}, locale_this.animation_duration);
}
);
},
resize: function ()
{
local_this = this;
jQuery(window).resize(gag = function ()
{
local_this.initial_start_widths();
});
},
unbind: function ()
{
jQuery(window).unbind('resize', gag);
jQuery('#' + this.element_id).children().unbind('hover', gag_hover, gag_unhover)
}
}
slider.install('top-posts-list');
jQuery(document).ready(function ()
{
if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {
jQuery('.pinned_post_bg').css('background-attachment', 'scroll');
}
if (!jQuery('header').find('.bwg_slideshow_image_wrap').length && !jQuery('header').find('.parallax_header').length) {
jQuery('#blog h2.page-header').css({"position": "static", "padding": "0"});
jQuery('aside').css("margin-top", "15px");
jQuery('.home aside').css("margin-top", "60px");
}
if (jQuery('.page-header').html() == "")
jQuery('.page-header').addClass("notitle");
jQuery('#top-nav li:has(> ul)').addClass('haschild');
jQuery("#top-nav > div > ul li,#top-nav > div > div > ul li").hover(function ()
{
jQuery(this).parent("ul").children().removeClass("active");
jQuery(this).addClass("active");
jQuery(this).find(">ul").slideDown("fast");
/*horizontall scroll prevention*/
{
if (jQuery(this).find('ul').eq(0).length && !matchMedia('only screen and (max-width : 767px)').matches) {
open_submenu = jQuery(this).find('ul').eq(0);
sub_left = open_submenu.offset().left;
sub_width = open_submenu.width();
current_left = open_submenu.position().left;
parent_class = function (classname)
{
return open_submenu.parent().parent().hasClass(classname);
}
parent_mainmenu = function ()
{
return !open_submenu.parent().parent().parent().hasClass('haschild');
}
if (/*parent_left +*/ sub_left + sub_width > jQuery(window).width() - 24) {
if (parent_class('sub_d_shift')) {
/*parent also shifted*/
open_submenu.addClass('sub_shift');
open_submenu.css({left: current_left + jQuery(window).width() - 24 - sub_left - sub_width});
}
else {
if (parent_mainmenu()) { // main menu
open_submenu.addClass('sub_shift');
open_submenu.css({left: current_left + jQuery(window).width() - 24 - sub_left - sub_width});
}
else {
parent_w = open_submenu.parent().parent().width();
open_submenu.addClass('sub_d_shift');
open_submenu.css({left: -sub_width});
}
}
}
}
}
}, function ()
{
if (matchMedia('screen and (max-width : 767px)').matches) {
/*phone(false);
*/
}
jQuery(this).parent("ul").children().removeClass("active");
jQuery(this).find(">ul").slideUp(100);
jQuery(".opensub").removeClass("opensub");
});
jQuery(window).resize(function ()
{
wdwt_reset_submenus();
});
jQuery("#top-nav > div > ul li.haschild > a,#top-nav > div > div > ul li.haschild > a").click(function ()
{
if (matchMedia('screen and (max-width : 767px)').matches || matchMedia('screen and (min-width: 768px) and (max-width: 1024px)').matches) {
if (jQuery(this).parent().hasClass("open")) {
jQuery(this).parent().parent().find(".haschild ul").slideUp(100);
jQuery(this).parent().removeClass("open");
return false;
}
jQuery(this).parent().parent().find(".haschild ul").slideUp(100);
jQuery(this).parent().parent().find(".haschild").removeClass("open");
jQuery(this).next("ul").slideDown("fast");
jQuery(this).parent().addClass("open");
return false;
}
});
jQuery("#header .phone-menu-block").on("click", "#menu-button-block", function ()
{
if (jQuery("#top-nav").hasClass("open")) {
jQuery("#header #top-nav").slideUp("fast");
jQuery("#top-nav").removeClass("open");
}
else {
jQuery("#header #top-nav").slideDown("slow");
jQuery("#top-nav").addClass("open");
}
});
/*##############CATEGORIES TABS####################*/
jQuery("#wd-horizontal-tabs ul.tabs").width(jQuery("#wd-horizontal-tabs ul.tabs li").length * jQuery("#wd-horizontal-tabs ul.tabs li").width());
jQuery("#tabs_content").width(jQuery("#tabs_div").width() - 32);
if (jQuery("#wd-horizontal-tabs ul.tabs").width() > jQuery("#tabs_content").width()) {
var visibleCount = jQuery("#tabs_content").width() / jQuery("#wd-horizontal-tabs ul.tabs li").width();
//jQuery("#wd-horizontal-tabs ul.tabs").css("left", -((jQuery("#wd-horizontal-tabs ul.tabs li").length - visibleCount - 1)*jQuery("#wd-horizontal-tabs ul.tabs li").width()));
}
/* HIDE SHOW ARROWS */
if (jQuery("#wd-horizontal-tabs ul.tabs").width() < jQuery("#tabs_content").width()) {
jQuery("#wd-horizontal-tabs #tabs_content").css("left", "0px");
jQuery("#tabs_left_arrow").hide();
jQuery("#tabs_right_arrow").hide();
}
else {
jQuery("#wd-horizontal-tabs #tabs_content").css("left", "16px");
jQuery("#tabs_left_arrow").show();
jQuery("#tabs_right_arrow").show();
}
jQuery("#wd-horizontal-tabs ul.content li:first-of-type").addClass("active");
jQuery("#wd-horizontal-tabs ul.tabs li:first-of-type").addClass("active");
var last_child_src = jQuery("#wd-horizontal-tabs ul.tabs li:first-of-type img").attr('src');
jQuery("#main_img img").attr('src', last_child_src);
jQuery("#wd-horizontal-tabs ul.tabs li a").click(function ()
{
jQuery("#wd-horizontal-tabs ul.tabs li").removeClass("active");
var id = jQuery(this).parent().attr("id").replace("horizontal-tab-", "");
var img_src = jQuery(this).children().attr('src');
jQuery(this).parent().addClass("active");
jQuery("#main_img img").attr('src', img_src);
jQuery("#wd-horizontal-tabs ul.content > li.active").css("display", "none").removeClass("active");
jQuery("#horizontal-tabs-content-" + id).fadeIn(600).addClass("active");
return false;
});
/* SCROLL */
var mousewheelevt = (/Firefox/i.test(navigator.userAgent)) ? "DOMMouseScroll" : "mousewheel";
jQuery('#tabs_content').on(mousewheelevt, function (e)
{
var evt = window.event || e;
evt = evt.originalEvent ? evt.originalEvent : evt;
var delta = evt.detail ? evt.detail * (-40) : evt.wheelDelta;
if (delta > 0) {
jQuery("#tabs_left_arrow").trigger('click');
}
else {
jQuery("#tabs_right_arrow").trigger('click');
}
e.preventDefault();
});
/* SWIPE */
if (typeof jQuery().swiperight !== 'undefined') {
if (jQuery.isFunction(jQuery().swiperight)) {
jQuery("#tabs_content").swiperight(function ()
{
jQuery("#tabs_left_arrow").trigger('click');
return false;
});
}
}
if (typeof jQuery().swipeleft !== 'undefined') {
if (jQuery.isFunction(jQuery().swipeleft)) {
jQuery("#tabs_content").swipeleft(function ()
{
jQuery("#tabs_right_arrow").trigger('click');
return false;
});
}
}
jQuery(window).resize(function ()
{
jQuery("#tabs_content").width(jQuery("#tabs_div").width() - 32);
//var left_right = Math.floor(jQuery("#tabs_content").width()/117);
var activel = jQuery("#wd-horizontal-tabs .tabs li.active").index() * 117;
var right_or_left = jQuery("#wd-horizontal-tabs ul.tabs").width() - jQuery("#tabs_content").width();
if (activel >= right_or_left) var active_elemo = right_or_left;
else var active_elemo = activel;
jQuery("#wd-horizontal-tabs ul.tabs").css("left", -active_elemo);
jQuery("#tabs_right_arrow, #tabs_left_arrow").removeAttr("style");
});
/* CLICK */
jQuery("#tabs_right_arrow").click(function ()
{
jQuery("#wd-horizontal-tabs ul.tabs").stop(true, false);
if (jQuery("#wd-horizontal-tabs ul.tabs").position().left >= -(jQuery("#wd-horizontal-tabs ul.tabs").width() - jQuery("#tabs_content").width())) {
jQuery("#tabs_left_arrow").css({opacity: 1, filter: "Alpha(opacity=100)", pointerEvents: "initial"});
if (jQuery("#wd-horizontal-tabs ul.tabs").position().left < -(jQuery("#wd-horizontal-tabs ul.tabs").width() - jQuery("#tabs_content").width() - 117)) {
jQuery("#wd-horizontal-tabs ul.tabs").animate({left: -(jQuery("#wd-horizontal-tabs ul.tabs").width() - jQuery("#tabs_content").width())}, 500, 'linear');
}
else {
jQuery("#wd-horizontal-tabs ul.tabs").animate({left: (jQuery("#wd-horizontal-tabs ul.tabs").position().left - 117)}, 500, 'linear');
}
}
window.setTimeout(function ()
{
if (jQuery("#wd-horizontal-tabs ul.tabs").position().left == -(jQuery("#wd-horizontal-tabs ul.tabs").width() - jQuery("#tabs_content").width())) {
jQuery("#tabs_right_arrow").css({opacity: 0.3, filter: "Alpha(opacity=30)", pointerEvents: "none"});
}
}, 500);
});
jQuery("#tabs_left_arrow").click(function ()
{
jQuery("#wd-horizontal-tabs ul.tabs").stop(true, false);
if (jQuery("#wd-horizontal-tabs ul.tabs").position().left < 0) {
jQuery("#tabs_right_arrow").css({opacity: 1, filter: "Alpha(opacity=100)", pointerEvents: "initial"});
if (jQuery("#wd-horizontal-tabs ul.tabs").position().left > -117) {
jQuery("#wd-horizontal-tabs ul.tabs").animate({left: 0}, 500, 'linear');
}
else {
jQuery("#wd-horizontal-tabs ul.tabs").animate({left: (jQuery("#wd-horizontal-tabs ul.tabs").position().left + 117)}, 500, 'linear');
}
}
window.setTimeout(function ()
{
if (jQuery("#wd-horizontal-tabs ul.tabs").position().left == 0) {
jQuery("#tabs_left_arrow").css({opacity: 0.3, filter: "Alpha(opacity=30)", pointerEvents: "none"});
}
}, 500);
});
/*Dotted Navigation*/
if (jQuery(".dotted_navigation").length) {
var section_count = jQuery(".home_section").length;
if (section_count > 1) {
for (var i = 0; i < section_count; i++) {
jQuery(".dotted_navigation").append("");
}
jQuery(".dotted_navigation").css("margin-top", -(jQuery(".dotted_navigation").outerHeight() / 2) + "px");
}
}
jQuery(".dotted_nav_item").on("click", function ()
{
var el_index = jQuery('.dotted_nav_item').index(this);
/*jQuery(".dotted_nav_item").removeClass("active");
jQuery(this).addClass("active");*/
var home_section_pos = jQuery(".home_section").eq(el_index).offset().top;
if (jQuery("#wpadminbar").length) {
home_section_pos = home_section_pos - 32;
}
jQuery("html, body").animate({scrollTop: home_section_pos}, 500);
});
function wdwt_reset_submenus()
{
/*reset submenu openings*/
jQuery('#top-nav > div ul.sub-menu').css({left: ''});
jQuery('#top-nav > div ul.sub_shift').removeClass('sub_shift');
jQuery('#top-nav > div ul.sub_d_shift').removeClass('sub_d_shift');
}
});
jQuery(window).scroll(function ()
{
var height = jQuery(window).scrollTop();
jQuery(".home_section").each(function (index, el)
{
if (jQuery(".home_section").eq(index + 1).length) {
if (height > jQuery(el).offset().top - 50 && height < jQuery(".home_section").eq(index + 1).offset().top - 50) {
jQuery('.dotted_nav_item').eq(index).addClass("active");
}
else {
jQuery('.dotted_nav_item').eq(index).removeClass("active");
}
} else {
if (height > jQuery(el).offset().top - 50) {
jQuery('.dotted_nav_item').eq(index).addClass("active");
}
else {
jQuery('.dotted_nav_item').eq(index).removeClass("active");
}
}
});
});
// source --> http://www.sleepandgo.es/wp-content/themes/business-world/inc/js/jquery-hover-effect.js?ver=1.1.26
(function( jQuery, undefined ) {
/*
* HoverDir object.
*/
$ = jQuery;
$.HoverDir = function( options, element ) {
this.$el = $( element );
this._init( options );
};
$.HoverDir.defaults = {
hoverDelay : 0,
reverse : false
};
$.HoverDir.prototype = {
_init : function( options ) {
this.options = $.extend( true, {}, $.HoverDir.defaults, options );
// load the events
this._loadEvents();
},
_loadEvents : function() {
var _self = this;
this.$el.on( 'mouseenter.hoverdir, mouseleave.hoverdir', function( event ) {
var $el = $(this),
evType = event.type,
$hoverElem = $el.find( 'article' ),
direction = _self._getDir( $el, { x : event.pageX, y : event.pageY } ),
hoverClasses= _self._getClasses( direction );
$hoverElem.removeClass();
if( evType === 'mouseenter' ) {
$hoverElem.hide().addClass( hoverClasses.from );
clearTimeout( _self.tmhover );
_self.tmhover = setTimeout( function() {
$hoverElem.show( 0, function() {
$(this).addClass( 'da-animate' ).addClass( hoverClasses.to );
} );
}, _self.options.hoverDelay );
}
else {
$hoverElem.addClass( 'da-animate' );
clearTimeout( _self.tmhover );
$hoverElem.addClass( hoverClasses.from );
}
} );
},
// credits : http://stackoverflow.com/a/3647634
_getDir : function( $el, coordinates ) {
/** the width and height of the current div **/
var w = $el.width(),
h = $el.height(),
/** calculate the x and y to get an angle to the center of the div from that x and y. **/
/** gets the x value relative to the center of the DIV and "normalize" it **/
x = ( coordinates.x - $el.offset().left - ( w/2 )) * ( w > h ? ( h/w ) : 1 ),
y = ( coordinates.y - $el.offset().top - ( h/2 )) * ( h > w ? ( w/h ) : 1 ),
/** the angle and the direction from where the mouse came in/went out clockwise (TRBL=0123);**/
/** first calculate the angle of the point,
add 180 deg to get rid of the negative values
divide by 90 to get the quadrant
add 3 and do a modulo by 4 to shift the quadrants to a proper clockwise TRBL (top/right/bottom/left) **/
direction = Math.round( ( ( ( Math.atan2(y, x) * (180 / Math.PI) ) + 180 ) / 90 ) + 3 ) % 4;
return direction;
},
_getClasses : function( direction ) {
var fromClass, toClass;
switch( direction ) {
case 0:
// from top
( !this.options.reverse ) ? fromClass = 'da-slideFromTop' : fromClass = 'da-slideFromBottom';
toClass = 'da-slideTop';
break;
case 1:
// from right
( !this.options.reverse ) ? fromClass = 'da-slideFromRight' : fromClass = 'da-slideFromLeft';
toClass = 'da-slideLeft';
break;
case 2:
// from bottom
( !this.options.reverse ) ? fromClass = 'da-slideFromBottom' : fromClass = 'da-slideFromTop';
toClass = 'da-slideTop';
break;
case 3:
// from left
( !this.options.reverse ) ? fromClass = 'da-slideFromLeft' : fromClass = 'da-slideFromRight';
toClass = 'da-slideLeft';
break;
};
return { from : fromClass, to: toClass };
}
};
var logError = function( message ) {
if ( this.console ) {
console.error( message );
}
};
$.fn.hoverdir = function( options ) {
if ( typeof options === 'string' ) {
var args = Array.prototype.slice.call( arguments, 1 );
this.each(function() {
var instance = $.data( this, 'hoverdir' );
if ( !instance ) {
logError( "cannot call methods on hoverdir prior to initialization; " +
"attempted to call method '" + options + "'" );
return;
}
if ( !$.isFunction( instance[options] ) || options.charAt(0) === "_" ) {
logError( "no such method '" + options + "' for hoverdir instance" );
return;
}
instance[ options ].apply( instance, args );
});
}
else {
this.each(function() {
var instance = $.data( this, 'hoverdir' );
if ( !instance ) {
$.data( this, 'hoverdir', new $.HoverDir( options, this ) );
}
});
}
return this;
};
})( jQuery );